#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
#include <string>
#include <cstring>
#define ldb long double
#define LL long long
#define fi first
#define se second
#define fill(a, c) memset(a, c, sizeof(a))
#define sqr(a) ((a) * (a))
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
#define getBit(mask, k) (((mask) / pw[k]) % pw[1])
#define setBit(mask, k, l) (((mask) / pw[k + 1] * pw[1] + (l)) * pw[k] + ((mask) % pw[k]))
#define debug(a) cerr << #a << " = " << a << " ";
#define debugl(a) cerr << #a << " = " << a << "\n";
const ldb LDINF = 9128739847123.00;
const ldb eps = 1e-9;
const int INF = 1 << 30;
const ldb pi = fabsl(atan2(0.0, -1.0));
using namespace std;
int n, m;
int *a;
int *l, *r, *u, *d;
int *was;

void newArr(int *&a, int n ,int m)
{
	a = new int[n * m];
}

int &ch(int *a, int i, int j)
{
	return *(a + i * m + j);
}

void Load()
{
	cin >> n >> m;
	nextLine();
	newArr(l, n, m);
	newArr(r, n, m);
	newArr(u, n, m);
	newArr(d, n, m);
	newArr(a, n, m );
	newArr(was, n, m);
	memset(was, 0, (sizeof(int)) * n * m);
	memset(a, 0, sizeof(int) * n * m);
	char c;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			scanf("%c", &c);
			ch(a, i, j) = c;
		}
		nextLine();
	}
}
int used;
inline void Del(int i, int j)
{
	if (ch(was, i, j) == used) return;
	if (i - ch(u, i, j) >= 0)
		ch(d, i - ch(u, i, j), j) += ch(d, i, j);
	if (i + ch(d, i, j) < n)
		ch(u, i + ch(d, i, j), j) += ch(u, i, j);
	if (j - ch(l, i, j) >= 0)
		ch(r, i, j - ch(l, i, j)) += ch(r, i, j);
	if (j + ch(r, i, j) < m)
		ch(l, i, j + ch(r, i, j)) += ch(l, i, j);
	ch(was, i, j) = used;	
}


inline int Up(int i, int j)
{
	int k;
	for (k = i - ch(u, i, j); k >= 0 && (ch(was, k, j) == used || ch(a, k, j) == '.'); k -= ch(u, k, j))
	{
		Del(k, j);
	}
	return k;
}

inline int Down(int i, int j)
{
	int k;
	for (k = i + ch(d, i, j); k < n && (ch(was, k, j) == used || ch(a, k, j) == '.'); k += ch(d, k, j))
	{
		Del(k, j);
	}
	return k;
}

inline int Left(int i, int j)
{
	int k;
	for (k = j - ch(l, i, j); k >= 0 && (ch(was, i, k) == used || ch(a, i, k) == '.'); k -= ch(l, i, k))
	{
		Del(i, k);
	}
	return k;
}

inline int Right(int i, int j)
{
	int k;
	for (k = j + ch(r, i, j); k < m && (ch(was, i, k) == used || ch(a, i, k) == '.'); k += ch(r, i, k))
	{
		Del(i, k);
	}
	return k;
}



int dfs(int i, int j)
{
	if (ch(was, i, j) == used) return 1;
	Del(i, j);
	
	if (ch(a, i, j) == 'U')
	{
		int k = Up(i, j);
		if (k >= 0 && ch(was, k, j) != used && ch(a, k, j) != '.')
			return dfs(k, j) + 1;
		return 1;
	}
	else if (ch(a, i, j) == 'D')
	{
		int k;
		k = Down(i, j);
		if (k < n && ch(was, k, j) != used && ch(a, k, j) != '.')
			return dfs(k, j) + 1;
		return 1;
	}
	else if (ch(a, i, j) == 'L')
	{
		int k = Left(i, j);
		if (k >= 0 && ch(was, i, k) != used && ch(a, i, k) != '.')
			return dfs(i, k) + 1;
		return 1;
	}
	else if (ch(a, i, j) == 'R')
	{
		int k;
		k = Right(i, j);
		if (k < m && ch(was, i, k) != used && ch(a, i, k) != '.')
			return dfs(i, k) + 1;
		return 0 + 1;
	}
	return 0;
}

void Solve()
{
	int cur = -1;
	int cnt = 0, res = -1;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			used++;
			for (int k = 0; k < n * m; k++)
			{
				ch(l, k / m, k % m) = 1;
				ch(r, k / m, k % m) = 1;
				ch(u, k / m, k % m) = 1;
				ch(d, k / m, k % m) = 1;
			}
			cur = dfs(i, j);
		//	cerr << i << " " << j << " " << cur << "\n";
			if (cur > res)
			{
				res = cur;
				cnt = 1;
			}
			else if (cur == res)
				cnt++;
		}
	}
	cout << res << " " << cnt;

}

#define file "c"
int main()
{
	#ifndef ONLINE_JUDGE
		freopen(file".in", "rt", stdin);
		freopen(file".out", "wt", stdout);
	#endif
	Load();
	Solve();
	return 0;
}
